# Contributor: Andrej Kolchin <KAAtheWise@protonmail.com>
# Maintainer: Andrej Kolchin <KAAtheWise@protonmail.com>
pkgname=carapace
pkgver=0.28.5
pkgrel=0
pkgdesc="Multi-shell multi-command argument completer"
url="https://rsteube.github.io/carapace-bin/"
arch="all"
license="MIT"
makedepends="go"
source="$pkgname-$pkgver.tar.gz::https://github.com/rsteube/carapace-bin/archive/v$pkgver.tar.gz"
# fixes the tar archive unpacking to carapace-bin-$pkgver
_pkgname=carapace-bin
builddir="$srcdir/$_pkgname-$pkgver"

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"
export GOFLAGS="$GOFLAGS -modcacherw"

build() {
	go generate ./cmd/carapace/...
	go build -tags release ./cmd/carapace
}

check() {
	# The two lone tests in the repository.
	# There is also 'completers/pandoc_completer/cmd/action', but it
	# shadows the release completer.
	go test ./cmd/carapace ./completers_release/pandoc_completer/cmd/action
}

package() {
	install -Dm755 carapace -t "$pkgdir"/usr/bin
}

sha512sums="
ce1746a05075afed1a394b424c8dc796f3c9a9215010fb4f716fde8c230f8a50b616e83883c292f524dff87697a2e5837b9739bb546dc8e58edcbe12f416df9b  carapace-0.28.5.tar.gz
"
